﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using DAL;
using DevExpress.Web.ASPxEditors;
using System.Web.Services;
using DevExpress.Web.ASPxGridView;
using System.Data;
using DevExpress.Web.ASPxTreeList;
using System.Data.SqlClient;
using System.Runtime.Remoting.Contexts;
public partial class PromotionInfo_EditPromotion : Frame.Pages.ActionInfomationEditBasePage
{
    protected override string ActionID
    {
        get { return "5001"; }
    }

    protected override string UserFunctions
    {
        get
        {
            if (CMSUser.Current.IsLogin)
            {
                if (CMSUser.Current.IsAdmin)
                {
                    return "IUDQ";
                }
                else
                {
                    return CMSUser.GetFunction(ActionID) != null ? CMSUser.GetFunction(ActionID).op : "";
                }
            }
            else
            {
                return "";
            }
        }
    }

    protected override bool IsShowSpecialFunctions
    {
        get
        {
            if (CMSUser.Current.IsLogin)
            {
                if (CMSUser.Current.IsAdmin)
                {
                    return true;
                }
                else
                {
                    return CMSUser.GetFunction(ActionID) != null ? (CMSUser.GetFunction(ActionID).op_s == "Y" ? true : false) : false;
                }
            }
            else
            {
                return false;
            }
        }
    }


    protected override void Page_Load(object sender, EventArgs e)
    {
        tvShow();
        int index = gridView.FocusedRowIndex;
        if (index == -1)
        {
            index = 0;
        }
        //if (!IsPostBack)
        //{
        //    ModelSetCx();
        //}
        base.Page_Load(sender, e);
    }
    void databind()
    {
        DataTable dt = new DataTable();
        dt = Frame.Global.GlobalSqlHelper.ExecuteSQLToDataTable("select * from css_sp_mjms");
        gridView.DataSourceID = "";
        gridView.DataSource = dt;
        gridView.KeyFieldName = "cxbh";
        gridView.DataBind();
    }
    void ModelSetCx()
    {
        DataTable dt = new DataTable();
        dt = Frame.Global.GlobalSqlHelper.ExecuteSQLToDataTable("select * from css_sp_mjms");
        gridView.DataSourceID = "";
        gridView.DataSource = dt;
        gridView.DataBind();
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            string flag = dt.Rows[i]["flag"].ToString();
            ASPxButton linkslqx = getAspxBtnTemplate(i, "btnQx");  //取消
            ASPxButton linkslsx = getAspxBtnTemplate(i, "btnSx");  //生效
            if (flag == "Y")
            {
                linkslsx.Text = "已生效";
                linkslsx.Enabled = false;
                linkslqx.Enabled = false;

            }
            else if (flag == "N")
            {
                linkslqx.Text = "已取消";
                linkslqx.Enabled = false;
                linkslsx.Enabled = false;
            }
        }
    }
    ASPxButton getAspxBtnTemplate(int index, string ControlName)
    {
        ASPxButton linksl = gridView.FindRowCellTemplateControl(index, (GridViewDataColumn)gridView.Columns[24], ControlName) as ASPxButton;
        return linksl;
    }

    void ShowDetail()
    {
        int index = gridView.FocusedRowIndex;
        if (index == -1)
        {
            index = 0;
        }
        string cxbh = gridView.GetRowValues(index, "cxbh").ToString();
        using (DataClassesDataContext lqdb = new DataClassesDataContext())
        {
            css_sp_mjms_mx mjm = lqdb.css_sp_mjms_mx.FirstOrDefault(r => r.cxbh == cxbh);
            txtcxbm.Text = cxbh;
            txtbz.Text = mjm.bz;
            lblspbm.Text = mjm.spbm;
            cmbflag_sqs.Value = mjm.flag_sq;
            cmbflag_zqs.Value = mjm.flag_zq;
        }
    }
    void ShowDetails(int index)
    {
        using (DataClassesDataContext lqdb = new DataClassesDataContext())
        {
            if (lqdb.css_sp_mjms.Count() > 0)
            {

                if (index != -1)
                {
                    string cxbh = gridView.GetRowValues(index, "cxbh").ToString();
                    txtcxbm.Text = cxbh;    //促销编号

                    int number = lqdb.css_sp_mjms.Count() + 1; //记录序号
                    var result = lqdb.css_sp_mjms_mx.FirstOrDefault(p => p.cxbh == cxbh && p.jlxh == number);  //检查是否已经存在
                    if (result != null)
                    {
                        txtcxbm.Text = cxbh;
                        txtbz.Text = result.bz;
                        lblspbm.Text = result.spbm;
                        cmbflag_sqs.Value = result.flag_sq;
                        cmbflag_zqs.Value = result.flag_zq;
                    }

                }


            }
        }

    }

    //初始化促销单元格生成促销编号
    protected void gridView_CellEditorInitialize(object sender, DevExpress.Web.ASPxGridView.ASPxGridViewEditorEventArgs e)
    {
        if (e.Column.FieldName == "cxbh")
        {
            if (e.Value == null)
            {
                using (DataClassesDataContext lqdb = new DataClassesDataContext())
                {
                    int number = lqdb.css_sp_mjms.Count() + 1;
                    (e.Editor as ASPxTextBox).Text = WebUtility.GenerateCode(number.ToString(), 'C', 10);
                    //WebUtility.GenerateCode(number.ToString(),'C',10);
                }
            }
        }
        if (e.Column.FieldName == "sm")
        {
            e.Editor.Focus();
        }
        e.Editor.SetClientSideEventHandler("KeyPress", @"function(s,e){var key = event.keyCode;if( key==13){EnterAsTab();}}");
    }

    #region  促销管理 赠 删 改
    //修改
    protected void gridView_RowUpdating(object sender, DevExpress.Web.Data.ASPxDataUpdatingEventArgs e)
    {
        #region
        //using (DataClassesDataContext lqdb = new DataClassesDataContext())
        //{
        //    var mjm = lqdb.css_sp_mjms.FirstOrDefault(m => m.cxbh == e.NewValues["cxbh"].ToString());
        //    if (e.NewValues["sm"] != null)
        //        mjm.sm = e.NewValues["sm"].ToString();
        //    if (e.NewValues["cxfs"] != null)
        //        mjm.cxfs = e.NewValues["cxfs"].ToString();
        //    mjm.xsje1 = Convert.ToInt32(e.NewValues["sxje1"]);
        //    mjm.hdje1 = Convert.ToInt32(e.NewValues["hdje1"]);
        //    mjm.sxje1 = Convert.ToInt32(e.NewValues["sxje1"]);
        //    mjm.xsje2 = Convert.ToInt32(e.NewValues["sxje2"]);
        //    mjm.hdje2 = Convert.ToInt32(e.NewValues["hdje2"]);
        //    mjm.sxje2 = Convert.ToInt32(e.NewValues["sxje2"]);
        //    if (e.NewValues["qsrq"] != null)
        //        mjm.qsrq = e.NewValues["qsrq"].ToString();
        //    if (e.NewValues["zzrq"] != null)
        //        mjm.zzrq = e.NewValues["zzrq"].ToString();
        //    if (e.NewValues["xpsm"] != null)
        //        mjm.xpsm = e.NewValues["xpsm"].ToString();
        //    if (e.NewValues["flag_zq"] != null)
        //        mjm.flag_zq = e.NewValues["flag_zq"].ToString();
        //    if (e.NewValues["zqje"] != null)
        //        mjm.zqje = Convert.ToInt32(e.NewValues["zqje"]);
        //    if (e.NewValues["bz"] != null)
        //        mjm.bz = e.NewValues["bz"].ToString();
        //    mjm.editor = "admin";// CMSUser.Current.Name;
        //    mjm.edate = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
        //    lqdb.SubmitChanges();
        //}

        //ModelSetCx();
        #endregion
        e.NewValues["editor"] = CMSUser.Current.ID;// CMSUser.Current.Name;
        e.NewValues["edate"] = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
        //gridView.CancelEdit();
        //e.Cancel = true;

    }
    //添加
    protected void gridView_RowInserting(object sender, DevExpress.Web.Data.ASPxDataInsertingEventArgs e)
    {
        #region
        //using (DataClassesDataContext lqdb = new DataClassesDataContext())
        //{
        //    css_sp_mjms mjm = new css_sp_mjms();
        //    mjm.cxbh = e.NewValues["cxbh"].ToString();
        //    if (e.NewValues["sm"] != null)
        //        mjm.sm = e.NewValues["sm"].ToString();
        //    if (e.NewValues["cxfs"] != null)
        //        mjm.cxfs = e.NewValues["cxfs"].ToString();
        //    mjm.xsje1 = Convert.ToInt32(e.NewValues["sxje1"]);
        //    mjm.hdje1 = Convert.ToInt32(e.NewValues["hdje1"]);
        //    mjm.sxje1 = Convert.ToInt32(e.NewValues["sxje1"]);
        //    mjm.xsje2 = Convert.ToInt32(e.NewValues["sxje2"]);
        //    mjm.hdje2 = Convert.ToInt32(e.NewValues["hdje2"]);
        //    mjm.sxje2 = Convert.ToInt32(e.NewValues["sxje2"]);
        //    if (e.NewValues["qsrq"] != null)
        //        mjm.qsrq = e.NewValues["qsrq"].ToString();
        //    if (e.NewValues["zzrq"] != null)
        //        mjm.zzrq = e.NewValues["zzrq"].ToString();
        //    if (e.NewValues["xpsm"] != null)
        //        mjm.xpsm = e.NewValues["xpsm"].ToString();
        //    if (e.NewValues["flag_zq"] != null)
        //        mjm.flag_zq = e.NewValues["flag_zq"].ToString();
        //    if (e.NewValues["zqje"] != null)
        //        mjm.zqje = Convert.ToInt32(e.NewValues["zqje"]);
        //    if (e.NewValues["bz"] != null)
        //        mjm.bz = e.NewValues["bz"].ToString();
        //    mjm.founder = "admin";// CMSUser.Current.Name;
        //    mjm.fdate = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
        //    mjm.editor = "admin";// CMSUser.Current.Name;
        //    mjm.edate = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
        //    lqdb.css_sp_mjms.InsertOnSubmit(mjm);
        //    lqdb.SubmitChanges();
        //}
        //gridView.CancelEdit();
        //e.Cancel = true;
        //ModelSetCx();
        #endregion
        e.NewValues["founder"] = CMSUser.Current.ID;// CMSUser.Current.Name;
        e.NewValues["fdate"] = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
        e.NewValues["editor"] = CMSUser.Current.ID;// CMSUser.Current.Name;
        e.NewValues["edate"] = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");

    }
    //级联删除
    protected void gridView_RowDeleting(object sender, DevExpress.Web.Data.ASPxDataDeletingEventArgs e)
    {
        using (DataClassesDataContext lqdb = new DataClassesDataContext())
        {
            int index = gridView.FocusedRowIndex;
            if (index == -1)
            {
                index = 0;
            }
            string cxNum = gridView.GetRowValues(index, "cxbh").ToString();
            ////删除促销信息
            //var mjm = lqdb.css_sp_mjms.FirstOrDefault(m => m.cxbh == cxNum);
            //if (mjm != null)
            //{
            //    lqdb.css_sp_mjms.DeleteOnSubmit(mjm);
            //    lqdb.SubmitChanges();
            //}
            //删除此促销信息下的详细信息
            var result = lqdb.css_sp_mjms_mx.FirstOrDefault(o => o.cxbh == cxNum);
            if (result != null)
            {
                lqdb.css_sp_mjms_mx.DeleteOnSubmit(result);
                lqdb.SubmitChanges();
            }
        }
        //ModelSetCx();
        //gridView.CancelEdit();
        //e.Cancel = true;

    }
    #endregion




    //ajax客户端获取数据  获取促销明细详细信息
    [WebMethod]
    public static string[] GetDet(string cxbh)
    {
        using (DataClassesDataContext context = new DataClassesDataContext())
        {
            string[] Lists = new string[5];
            var bz = context.css_sp_mjms_mx.Where(u => u.cxbh.Trim() == cxbh.Trim()).Select(u => u.bz).ToArray();
            var spbm = context.css_sp_mjms_mx.Where(u => u.cxbh.Trim() == cxbh.Trim()).Select(u => u.spbm).ToArray();
            var flag_sp = context.css_sp_mjms_mx.Where(u => u.cxbh.Trim() == cxbh.Trim()).Select(u => u.flag_sq).ToArray();
            var flag_zp = context.css_sp_mjms_mx.Where(u => u.cxbh.Trim() == cxbh.Trim()).Select(u => u.flag_zq).ToArray();
            string spbms = spbm[0];
            var spmc = context.css_spjbxx.Where(s => s.spbm.Trim() == spbms.Trim()).Select(s => s.spmc).ToArray();
            Lists[0] = bz[0];
            Lists[1] = spbm[0];
            Lists[2] = flag_sp[0];
            Lists[3] = flag_zp[0];
            Lists[4] = spmc[0];
            return Lists;
        }
    }

    //促销生效
    protected void btnSx_Click(object sender, EventArgs e)
    {
        using (DataClassesDataContext lqdb = new DataClassesDataContext())
        {
            int index = gridView.FocusedRowIndex;
            if (index == -1)
            {
                index = 0;
            }
            string cxbhs = gridView.GetRowValues(index, "cxbh").ToString();
            var result = lqdb.css_sp_mjms.FirstOrDefault(o => o.cxbh == cxbhs);
            result.flag = "Y";  //生效标志
            result.sxrq = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");   //生效日期
            lqdb.SubmitChanges();

            string flagdy = gridView.GetRowValues(index, "flag_zq").ToString(); //是否打印赠卷
            if (flagdy == "Y")
            {
                //是否赠卷 填写赠卷信息

                int zqje = Convert.ToInt32(gridView.GetRowValues(index, "zqje"));//获取单张赠卷金额
                string jzrq = gridView.GetRowValues(index, "zzrq").ToString();               //获取促销截至日期
                int number = lqdb.css_sp_coup.Count() + 1;
                css_sp_coup coup = new css_sp_coup();
                coup.zqbh = "Z" + WebUtility.GenerateCode(number.ToString(), 'C', 10);  //赠卷编号
                //获取单张赠券金额
                coup.fsje = Convert.ToInt32(zqje);     //??计算中
                coup.cxbh = cxbhs;                     //促销编号
                coup.zdh1 = "000";                                     //生成终端号
                coup.jyh1 = 1000;                                      //生成交易号
                coup.fsrq1 = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");  //生成日期
                coup.zdh2 = "001";                                     //使用终端号
                coup.jyh2 = 1001;                                      //使用交易号
                coup.fsrq2 = "";  //使用日期
                coup.jzrq = jzrq;  //截至日期
                coup.flag = "Y";                    //是否有效
                lqdb.css_sp_coup.InsertOnSubmit(coup);
                lqdb.SubmitChanges();
            }

            databind();
            //ModelSetCx();
        }

    }
    //促销取消
    protected void btnQx_Click(object sender, EventArgs e)
    {
        using (DataClassesDataContext lqdb = new DataClassesDataContext())
        {
            int index = gridView.FocusedRowIndex;
            if (index == -1)
            {
                index = 0;
            }

            string cxbhs = gridView.GetRowValues(index, "cxbh").ToString();
            var result = lqdb.css_sp_mjms.FirstOrDefault(o => o.cxbh == cxbhs);
            result.flag = "N";//生效标志
            result.qxrq = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");   //取消日期
            lqdb.SubmitChanges();
            //ModelSetCx();
            databind();
        }

    }

    #region 生效门店操作 treeview
    // 将数据绑定到treeview中
    private void tvShow()
    {
        DataTable dt = Frame.Global.GlobalSqlHelper.ExecuteSQLToDataTable("select * from css_department order by bmbm");
        this.DxTreelist.DataSource = dt;
        this.DxTreelist.DataBind();
    }
    //ajax客户端获取数据
    [WebMethod]
    public static string[] GetParts(string sxfw)
    {
        using (DataClassesDataContext context = new DataClassesDataContext())
        {
            string[] bmbm = sxfw.Split(',');
            return bmbm;
        }
    }
    //保存生效门店信息
    protected void QueryCBPanel_Callback(object sender, DevExpress.Web.ASPxClasses.CallbackEventArgsBase e)
    {

        //得到从客户端传递过来的参数来进行异步通信响应
        string sxfw = "";
        if (this.DxTreelist.GetSelectedNodes().Count > 0)
        {
            List<TreeListNode> selection = this.DxTreelist.GetSelectedNodes();
            //遍历node并连接成字符串
            foreach (TreeListNode node in selection)
            {
                sxfw = sxfw + node.GetValue("bmbm") + ",";
            }
        }

        List<SqlParameter> Params = new List<SqlParameter>();
        Params.Add(new SqlParameter("@cxbh", e.Parameter));
        Params.Add(new SqlParameter("@sxfw", sxfw));
        Frame.Global.GlobalSqlHelper.ExcuteSQLScalar("update css_sp_mjms set sxfw=@sxfw where cxbh=@cxbh", Params.ToArray());
    }
    //读取生效门店信息
    protected void DxTreelist_CustomCallback(object sender, TreeListCustomCallbackEventArgs e)
    {
        // string cxNum = gridView.GetSelectedFieldValues("cxbh").ToString();

        int index = gridView.FocusedRowIndex;
        if (index == -1)
        {
            Frame.Global.GlobalFunctions.Alert("请在下方选择促销方式！");
        }
        else
        {
            string cxbh = gridView.GetRowValues(index, "cxbh").ToString();
            string[] Sxfws;
            string sxfw = Frame.Global.GlobalSqlHelper.ExcuteSQLScalar("select sxfw from css_sp_mjms where cxbh='" + cxbh + "'").ToString();
            Sxfws = sxfw.Split(',');
            //清除所有选择
            for (int i = 0; i < this.DxTreelist.Nodes.Count; i++)
            {
                this.DxTreelist.Nodes[i].Selected = false;
            }

            if (Sxfws.Length > 0)
            {
                for (int i = 0; i < Sxfws.Length; i++)
                {
                    if (!Sxfws[i].Equals(""))
                    {
                        TreeListNode selection = DxTreelist.FindNodeByKeyValue(Sxfws[i]);
                        if (selection != null)
                        {
                            selection.Selected = true;
                        }
                    }
                }
            }
        }

    }
    #endregion

    //促销登记详情
    //protected void btnDetails_Click(object sender, EventArgs e)
    //{
    //    using (DataClassesDataContext lqdb = new DataClassesDataContext())
    //    {
    //        int index = gridView.FocusedRowIndex;
    //        string cxNum = gridView.GetSelectedFieldValues("cxbh").ToString();
    //        string cxNum = gridView.GetRowValues(index, "cxbh").ToString();
    //        gvShowDetails.DataSourceID = "";
    //        gvShowDetails.DataSource = lqdb.css_sp_mjms_mx.Where(o => o.cxbh == cxNum);
    //        gvShowDetails.DataBind();
    //    }
    //}



    #region 促销详情
    //详情生效
    protected void btnSxD_Click(object sender, EventArgs e)
    {
        if (isEmpty() == true)
        {
            using (DataClassesDataContext lqdb = new DataClassesDataContext())
            {
                int index = gridView.FocusedRowIndex;
                if (index == -1)
                {
                    index = 0;
                }
                string cxbhs = gridView.GetRowValues(index, "cxbh").ToString();               //促销编号
                var result = lqdb.css_sp_mjms_mx.FirstOrDefault(o => o.cxbh == cxbhs);
                result.flag = "Y";//生效标志
                result.sxrq = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");   //生效日期
                lqdb.SubmitChanges();

                //是否赠卷 填写赠卷信息
                //如果使用赠券则将赠券信息录入
                int number = lqdb.css_sp_coup.Count() + 1;
                css_sp_coup coup = new css_sp_coup();
                coup.zqbh = "Z" + WebUtility.GenerateCode(number.ToString(), 'C', 10);  //赠卷编号
                //获取单张赠券金额
                string zqje = gridView.GetRowValues(index, "zqje").ToString();
                coup.fsje = Convert.ToInt32(zqje);     //??计算中
                coup.cxbh = gridView.GetRowValues(index, "cxbh").ToString();             //促销编号
                coup.zdh1 = "000";                                     //生成终端号
                coup.jyh1 = 1000;                                      //生成交易号
                coup.fsrq1 = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");  //生成日期
                coup.zdh2 = "001";                                     //使用终端号
                coup.jyh2 = 1001;                                      //使用交易号
                coup.fsrq2 = "";  //使用日期
                coup.jzrq = gridView.GetRowValues(index, "zzrq").ToString();  //截至日期
                coup.flag = "Y";                    //是否有效
                lqdb.css_sp_coup.InsertOnSubmit(coup);
                lqdb.SubmitChanges();

            }
        }
        // ASPxPopupControl4
    }
    //详情取消
    protected void btnQxD_Click(object sender, EventArgs e)
    {
        if (isEmpty() == true)
        {
            using (DataClassesDataContext lqdb = new DataClassesDataContext())
            {
                int index = gridView.FocusedRowIndex;
                if (index == -1)
                {
                    index = 0;
                }
                string cxbhs = gridView.GetRowValues(index, "cxbh").ToString();

                var result = lqdb.css_sp_mjms_mx.FirstOrDefault(o => o.cxbh == cxbhs);
                result.flag = "N";//生效标志
                result.qxrq = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");   //取消日期
                lqdb.SubmitChanges();
            }
        }
    }

    // 判断有效性
    bool isEmpty()
    {
        //if (lblspbm.Text.Equals(""))
        //{
        //    Frame.Global.GlobalFunctions.Alert("请选择商品！");
        //    return false;
        //}
        //else 
        if (txtbz.Text.Equals(""))
        {
            Frame.Global.GlobalFunctions.Alert("请填写备注信息！");
            return false;
        }
        else
        {
            return true;
        }
    }
    //添加详细信息
    //保存产品编号   保存促销详情
    protected void ShowProduct_CustomCallback(object sender, ASPxGridViewCustomCallbackEventArgs e)
    {
        if (isEmpty() == true)
        {
            using (DataClassesDataContext lqdb = new DataClassesDataContext())
            {
                int index = gridView.FocusedRowIndex;
                if (index == -1)
                {
                    index = 0;
                }
                string cxbh = gridView.GetRowValues(index, "cxbh").ToString();
                txtcxbm.Text = cxbh;    //促销编号
                int number = lqdb.css_sp_mjms_mx.Count() + 1; //记录序号
                //var searchNum = lqdb.css_sp_mjms_mx.FirstOrDefault(r => r.cxbh == cxbh);
                var result = lqdb.css_sp_mjms_mx.FirstOrDefault(p => p.cxbh == cxbh && p.jlxh == number);  //检查是否已经存在
                if (result == null)
                {
                    result = new css_sp_mjms_mx();
                    result.cxbh = cxbh;
                    result.jlxh = number;
                    if (!cmbflag_sqs.Text.Equals(""))
                    {
                        result.flag_zq = cmbflag_zqs.Value.ToString();
                    }

                    if (!cmbflag_zqs.Text.Equals(""))
                    {
                        result.flag_sq = cmbflag_sqs.Value.ToString();
                    }
                    result.bz = txtbz.Text;
                    result.spbm = e.Parameters;     //商品编码
                    //result.founder = "0001";// CMSUser.Current.Name;
                    //result.fdate = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                    //result.editor = "0001";// CMSUser.Current.Name;
                    //result.editor = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                    lqdb.css_sp_mjms_mx.InsertOnSubmit(result);
                    lqdb.SubmitChanges();
                    Frame.Global.GlobalFunctions.Alert("操作成功！");
                }
                else
                {
                    var results = lqdb.css_sp_mjms_mx.FirstOrDefault(p => p.cxbh == cxbh && p.jlxh == number);
                    if (!cmbflag_sqs.Text.Equals(""))
                    {
                        result.flag_zq = cmbflag_zqs.Value.ToString();
                    }
                    if (!cmbflag_zqs.Text.Equals(""))
                    {
                        result.flag_sq = cmbflag_sqs.Value.ToString();
                    }
                    result.bz = txtbz.Text;
                    if (!labProid.Text.Equals("xxxxx"))
                    {
                        result.spbm = e.Parameters;
                    }
                    results.editor = CMSUser.Current.ID;
                    results.edate = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
                    lqdb.SubmitChanges();
                    Frame.Global.GlobalFunctions.Alert("操作成功！");
                }

            }
        }
    }

    #endregion

}